<template>
  <div>
    <h1>上传视频文件，限制为mp4格式</h1>
    <p>
      选择图片： <input type="file" id="send-pic">
    </p>
    <div>
<!--      <single-upload @get-instance="getInstance"/>-->
    </div>
  </div>

</template>

<script setup>
import {onMounted} from 'vue'
import {getVideoDuration} from '@/utils/FileUtils.js'
import {uploadFile} from "@/api/UploadRequest.js";


function getInstance(instance) {
  console.log('从子组件中获得实体',instance);
}

onMounted(_=>{
  document.querySelector('#send-pic').addEventListener('change', async function () {
    let files = this.files;
    if (files && files.length) {
      const file = files[0];
      console.log("文件",file);
      // const res = await uploadFile(file);
      getVideoDuration(file).then(time => {
        console.log("视频时长",time)
      })
    }
  }, false);
})



</script>